<template>
  <div class="screen">
    <div class="wrapper hero">
      <div class="hero-text">
        <h1 class="hero-title">
          <div
            class="animated-text-background animated-gradient-text-1"
            :style="{ '--hero-text-1': `'${$t('heroTitle1')}'` }"
          >
            <span class="animated-text-foreground-1">{{
              $t('heroTitle1')
            }}</span>
          </div>
          <div
            class="animated-text-background animated-gradient-text-2"
            :style="{ '--hero-text-2': `'${$t('heroTitle2')}'` }"
          >
            <span class="animated-text-foreground-2">{{
              $t('heroTitle2')
            }}</span>
          </div>
          <div
            class="animated-text-background animated-gradient-text-3"
            :style="{ '--hero-text-3': `'${$t('heroTitle3')}'` }"
          >
            <span class="animated-text-foreground-3">{{
              $t('heroTitle3')
            }}</span>
          </div>
        </h1>
      </div>
      <span class="spacer" style="margin-top: var(--space)"></span>
      <div class="hero-focus">
        <div class="hero-focus-item">
          <div class="hero-focus-icon">
            <i class="sight-icon-edit-3"></i>
          </div>
          <div class="hero-focus-wrapper">
            <p class="hero-focus--title">{{ $t('heroSectionTitle1') }}</p>
            <p class="hero-focus--subtitle">{{ $t('heroSectionSummary1') }}</p>
          </div>
        </div>
        <div class="hero-focus-item">
          <div class="hero-focus-icon">
            <i class="sight-icon-share"></i>
          </div>
          <div class="hero-focus-wrapper">
            <p class="hero-focus--title">{{ $t('heroSectionTitle2') }}</p>
            <p class="hero-focus--subtitle">{{ $t('heroSectionSummary2') }}</p>
          </div>
        </div>
        <div class="hero-focus-item">
          <div class="hero-focus-icon">
            <i class="sight-icon-code"></i>
          </div>
          <div class="hero-focus-wrapper">
            <p class="hero-focus--title">{{ $t('heroSectionTitle3') }}</p>
            <p class="hero-focus--subtitle">{{ $t('heroSectionSummary3') }}</p>
          </div>
        </div>
      </div>
      <span class="spacer" style="margin-top: var(--space)"></span>
      <h2 class="hero-description">
        <font
          >{{ $t('with') }}
          <a href="wissbell.com">{{ $t('copyright') }}</a>
          {{ $t('quote') }}</font
        ><br />
        <font>{{ $t('slogan') }}</font>
      </h2>
    </div>
    <div class="recommend">
      <div class="wrapper">
        <h2>{{ $t('hotPost') }}</h2>
        <p class="recommend-summary">{{ $t('hotPostSummary') }}</p>
        <div class="recommend-list">
          <div v-for="(post,i) in articles" :key="i" class="card" @click="goToArticle(post.slug)">
            <div v-if="post.image" class="card-figure">
              <img
                fit="cover"
                loading="lazy"
                :src="$config.STATIC_BASE + post.image + $config.STATIC_CLIP"
                :alt="post.title"
              />
            </div>
            <div class="card-content">
              <div class="card-title">{{post.title}}</div>
              <div class="card-copy">
                <p>
                  {{post.description}}
                </p>
              </div>
            </div>
            <div class="card-footer">
              <div class="author">
                <div class="avatar">
                  <img :src="$config.STATIC_BASE + '/author/'+ post.author.avatar" :alt="post.author.name" />
                </div>
                <a target="_blank" :href="post.author.link || '#'" class="name">@{{post.author.name}}</a>
              </div>
              <div class="date">{{formatDate(post.createdAt)}}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="topic">
      <div class="wrapper">
        <span class="spacer" style="margin-top: calc(var(--space) * 2)"></span>
        <h2 class="topic-title">{{ $t('topicTitle') }}</h2>
        <p class="topic-summary">{{ $t('topicSummary') }}</p>
        <div class="topic-list">
          <div class="card" @click="goToTopic('vue')">
            <div class="card-figure">
              <img :src="require('@/assets/symbol/vue.svg')" alt="vue logo" />
            </div>
            <div class="card-title">VueJs</div>
            <div class="card-summary">
              <a title="尤雨溪" target="_blank" href="https://evanyou.me/">{{
                $t('vueSummaryLink')
              }}</a
              >{{ $t('vueSummaryMain') }} <br />
              {{ $t('vueSummarySub') }}
            </div>
          </div>
          <div class="card" @click="goToTopic('react')">
            <div class="card-figure">
              <img :src="require('@/assets/symbol/react.svg')" alt="react logo" />
            </div>
            <div class="card-content">
              <div class="card-title">ReactJs</div>
              <div class="card-summary">
                <a title="m" target="_blank" href="https://meta.com/">
                  {{ $t('reactSummaryLink') }}
                </a>
                {{ $t('reactSummaryMain') }}<br />
                {{ $t('reactSummarySub') }}
              </div>
            </div>
          </div>
          <div class="card" @click="goToTopic('node')">
            <div class="card-figure">
              <img :src="require('@/assets/symbol/node.svg')" alt="node logo" />
            </div>
            <div class="card-title">NodeJs</div>
            <div class="card-summary">
              {{ $t('nodeSummaryMain') }}<br />{{ $t('nodeSummarySub') }}
            </div>
          </div>
          <div class="card" @click="goToTopic('webpack')">
            <div class="card-figure">
              <img :src="require('@/assets/symbol/webpack.svg')" alt="webpack logo" />
            </div>
            <div class="card-title">WebPack</div>
            <div class="card-summary">
              {{ $t('webpackSummaryMain') }}<br />{{ $t('webpackSummarySub') }}
            </div>
          </div>
          <div class="card" @click="goToTopic('visual')">
            <div class="card-figure">
              <img :src="require('@/assets/symbol/visualize.svg')" alt="visualize logo" />
            </div>
            <div class="card-title">Visualize</div>
            <div class="card-summary">
              {{ $t('visualizeSummaryMain') }}<br />{{
                $t('visualizeSummarySub')
              }}
            </div>
          </div>
          <div class="card" @click="goToTopic('app')">
            <div class="card-figure">
              <img :src="require('@/assets/symbol/hybrid.svg')" alt="hybrid logo" />
            </div>
            <div class="card-title">Hybrid</div>
            <div class="card-summary">
              <del>{{ $t('hybridSummarySpecial') }}</del
              >{{ $t('hybridSummaryMain') }}<br />{{ $t('hybridSummarySub') }}
            </div>
          </div>
        </div>
        <span
          class="spacer"
          style="margin-bottom: calc(var(--space) * 1.3)"
        ></span>
      </div>
    </div>
    <div class="sight has-border-top">
      <div class="wrapper">
        <div class="container sight-wrapper">
          <span
            class="spacer"
            style="margin-top: calc(var(--space) * 2)"
          ></span>
          <span class="caption uppercase">OPEN SOURCE</span>
          <h2 class="text-wrapper">
            {{ $t('bornIn')
            }}<a href="https://vercel.com/design" target="_blank"
              >vercel© design</a
            >
            {{ $t('language') }}
          </h2>
          <p class="sight-description">
            {{ $t('openSource') }}
          </p>
          <span class="spacer" style="margin-top: var(--space)"></span>
          <div class="bash">
            <div class="bash-header">
              <div class="bash-header-traffic">
                <span class="window-icon icon-close"></span>
                <span class="window-icon icon-minimize"></span>
                <span class="window-icon icon-fullscreen"></span>
              </div>
            </div>
            <div class="bash-body">
              <div class="bash-cli">$ <span>~/</span> cd frontend</div>
              <div class="bash-cli">
                $ <span>~/frontend# </span>git clone
                https://gitee.com/coke-code/sight.git
              </div>
               <div class="bash-cli">
                $ <span class="">~/frontend# </span>
                <span class="bash-cli-cursor">cd sight</span>
              </div>
              <div class="bash-cli">
                $ <span class="">~/frontend/sight# </span>
                <span class="bash-cli-cursor">npm i</span>
              </div>
              <div class="bash-cli bash-cli-current">
                $ <span class="">~/frontend/sight# </span>
                <span class="bash-cli-cursor">npm run dev</span>
              </div>
            </div>
          </div>
          <span
            class="spacer"
            style="margin-bottom: calc(var(--space) * 2)"
          ></span>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import dayjs from 'dayjs'
export default {
  name: 'Home',
  async asyncData({ i18n, app, $content, params }) {
    const locale = i18n.locale
    const articles = await $content('articles').where({ hot: 1, publish: 1 }).without(['body']).sortBy('createdAt','desc').limit(10).fetch()
    return {
      locale,
      articles
    }
  },
  data() {
    return {
    }
  },
  head() {
    return {
      title: '书里总爱写道喜出望外的傍晚'
    }
  },
  methods: {
    formatDate(date) {
      return dayjs(date).format('YYYY/MM/DD HH:mm:ss')
    },
    goToArticle(slug){
      this.$router.push(this.localePath(`/article/${slug}`))
    },
    goToTopic(tag){
      this.$router.push(this.localeLocation({
        path:'/posts',
        query:{
          tag
        }
      }))
    }
  },
}
</script>
<style lang="scss" scoped>
.hero {
  padding-bottom: 5rem;
  .hero-text {
    padding: 3rem 0;
  }
  .hero-title {
    font-size: 7rem;
  }
  .hero-focus {
    display: flex;
    justify-content: center;
  }
  .hero-focus-item {
    flex: 1;
    display: flex;
    justify-content: space-evenly;
    .hero-focus-icon {
      display: flex;
      justify-content: center;
      align-items: center;
      color: var(--background);
      margin-right: var(--space-4x);
      width: 40px;
      height: 40px;
      flex: 40px 0 0;
      border-radius: 100%;
      background: var(--foreground);
    }
  }
}

.hero-description {
  line-height: 1.6em !important;
  color: var(--secondary);
  font-weight: 400;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  text-align: center;
  margin: var(--gap-quarter) 0 var(--space-16x);
}
.animated-text-background {
  position: relative;
  display: block;
  text-align: center;
}
.animated-text-background::before {
  content: var(--content);
  position: absolute;
  display: block;
  width: 100%;
  color: var(--foreground);
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 0;
  padding-left: var(--padding);
  padding-right: var(--padding);
}
.animated-gradient-text-1 {
  --content: var(--hero-text-1);
  --padding: 0.05em;
  --start-color: #0dbedd;
  --end-color: #059488;
}
.animated-gradient-text-1::before {
  animation: animated-gradient-text_fade-background-1 8s infinite;
}
.animated-gradient-text-2 {
  --content: var(--hero-text-2);
  --padding: 0.05em;
  --start-color: #007cf0;
  --end-color: #00dfd8;
}
.animated-gradient-text-2::before {
  animation: animated-gradient-text_fade-background-2 8s infinite;
}
.animated-gradient-text-3 {
  --content: var(--hero-text-3);
  --padding: 0.05em;
  --start-color: #ff4d4d;
  --end-color: #f9cb28;
}
.animated-gradient-text-3::before {
  animation: animated-gradient-text_fade-background-3 8s infinite;
}

.animated-text-foreground-1 {
  animation: animated-gradient-text_fade-foreground-1 8s infinite;
}
.animated-text-foreground-2 {
  animation: animated-gradient-text_fade-foreground-2 8s infinite;
}
.animated-text-foreground-3 {
  animation: animated-gradient-text_fade-foreground-3 8s infinite;
}
.animated-text-background span {
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  padding-left: var(--padding);
  padding-right: var(--padding);
  background-image: linear-gradient(
    90deg,
    var(--start-color),
    var(--end-color)
  );
  position: relative;
  z-index: 1;
}

/** 热点 start */
.recommend {
  text-align: center;
}
.recommend-summary {
  margin-top: var(--space-mini);
}
.recommend-list {
  margin: var(--space-large);
  .card {
    display: flex;
    margin: var(--space-gap);
    overflow: hidden;
  }
  .card-title {
    color: var(--foreground);
    font-size: 1.5rem;
    letter-spacing: -0.029375rem;
    line-height: 2rem;
    font-weight: bold;
  }
  .card-figure {
    width: 300px;
    display: flex;
    margin-right: var(--gap-double);
    height: 180px;
    img {
      width: 300px;
      height: 180px;
      object-fit: cover;
      max-width: none;
      min-height: 150px;
    }
  }
  .card-copy {
    text-align: left;
    margin-top: var(--space-4x);
    min-height: 80px;
  }
  .card-copy p {
    color: var(--accents-5);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 7;
    -webkit-box-orient: vertical;
  }
  .card-content{
    display: flex;
    flex-direction: column;
    flex: 1;
  }
  .card-footer {
    width: 200px;
    justify-content: center;
    margin-left: var(--gap);
    color: var(--accents-5);
    font-size: 0.875rem;
    display: flex;
    flex-direction: column;
    & > * {
      margin-bottom: var(--space-2x);
    }
    .author {
      display: flex;
      align-items: center;
      align-self: center;
    }
    .avatar {
      display: flex;
      width: 30px;
      margin: var(--space-2x);
      img {
        width: 30px;
        height: 30px;
        object-fit: cover;
      }
    }
    .name {
      font-weight: bold;
      color: var(--violet);
    }
    .date {
      font-family: var(--font-mono);
    }
  }
}

/** 热点 end */

/** 专题 start */
.topic {
  text-align: center;
}
.topic-summary {
  margin-top: var(--space-mini);
}
.topic-list {
  display: flex;
  flex-wrap: wrap;
  margin: var(--space-large);
  justify-content: center;
  .card {
    width: 30%;
    min-width: 250px;
    background: var(--background);
    padding: var(--space-small) var(--gap);
    margin: var(--space-gap-half);
    .card-figure{
      img{
        width: 48px;
        height: 48px;
        object-fit: cover;
      }
    }
  }
  .card-title {
    font-weight: bolder;
    padding: var(--space-2x);
    color: var(--foreground);
  }
  .card-summary {
    color: var(--secondary);
    line-height: 1.5;
    padding: 0;
  }
}

.sight-wrapper {
  --justify-content: center;
  --align-items: center;
}
.sight-description {
  margin-top: var(--space-mini);
}
.caption {
  font-size: 0.875rem;
  font-weight: bold;
  letter-spacing: 0.15rem;
  line-height: 1.25rem;
  font-family: var(--font-sans);
  margin: 0;
  color: var(--violet);
}
.text-wrapper {
  margin-top: var(--space-mini);
}

/** 专题 end */

@media screen and (max-width: 900px) {
  .hero {
    padding-bottom: 2rem;
    .hero-text {
      padding: 2rem 0;
    }
    .hero-title {
      font-size: 5rem;
    }
    .hero-description {
      font-size: 1rem;
    }
  }
  .recommend {
    .card {
      flex-direction: column;
      align-items: center;
      padding: 0 0 var(--space-gap);
      .card-figure {
        width: 100%;
        margin: auto;
        img{
          width: 100%;
          height: auto;
        }
      }
      .card-content {
        margin: var(--space-gap)
      }
      .card-footer{
        margin: 0;
      }
    }
  }
}
@media screen and (max-width: 600px) {
  .hero {
    .hero-title {
      font-size: 2.3rem;
    }
    .hero-focus {
      width: 80%;
      margin: 0 auto;
      flex-direction: column;
      .hero-focus-item {
        margin: var(--space-4x);
      }
      .hero-focus-wrapper {
        min-width: 180px;
        flex: 1;
      }
    }
  }
  .sight-description {
    text-align: center;
  }
  .recommend .card {
    margin: var(--gap) 0;
  }
  .recommend .card .card-footer {
    flex-direction: column;
  }
  .recommend-list {
    margin: var(--space-small) 0;
  }
  .topic-list {
    margin: var(--space-small) 0;
  }
  .topic-list .card {
    width: 100%;
    margin: var(--space-gap-half) 0;
  }
}
@keyframes animated-gradient-text_fade-foreground-1 {
  0%,
  16.667%,
  to {
    opacity: 1;
  }

  33.333%,
  83.333% {
    opacity: 0;
  }
}

@keyframes animated-gradient-text_fade-background-1 {
  0%,
  16.667%,
  to {
    opacity: 0;
  }

  25%,
  91.667% {
    opacity: 1;
  }
}

@keyframes animated-gradient-text_fade-foreground-2 {
  0%,
  to {
    opacity: 0;
  }

  33.333%,
  50% {
    opacity: 1;
  }

  16.667%,
  66.667% {
    opacity: 0;
  }
}

@keyframes animated-gradient-text_fade-background-2 {
  0%,
  to {
    opacity: 1;
  }

  33.333%,
  50% {
    opacity: 0;
  }

  25%,
  58.333% {
    opacity: 1;
  }
}

@keyframes animated-gradient-text_fade-foreground-3 {
  0%,
  50%,
  to {
    opacity: 0;
  }

  66.667%,
  83.333% {
    opacity: 1;
  }
}

@keyframes animated-gradient-text_fade-background-3 {
  0%,
  58.333%,
  91.667%,
  to {
    opacity: 1;
  }

  66.667%,
  83.333% {
    opacity: 0;
  }
}
</style>
